<template>
	<div class="modal-mask" v-if="isShow" @click="close">
		<div class="modal-container">
			<div class="content">
				<slot></slot>
			</div>
		</div>
	</div>
</template>

<script>
export default {

	name: 'index',

	props: {
	  	name: String
	},

	data () {
	    return {
	    	isShow: false
	    };
	},

	created () {
	  	this.bus.$on(this.name, data => this.isShow = data);
	},

	methods: {
	  	close (e) {
	  		if (e.target.className === 'modal-mask') {
	  			this.bus.$emit(this.name, false);
	  		}
	  	}
	}
};
</script>

<style lang="scss" scoped>
	.modal-mask{
		position: fixed;
		top: 0;
		left: 0;
		z-index: 10000;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.5);

		.modal-container{
			width: 492px;
			background: #fff;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
			border-radius: 20px;

			.content{
				// padding: 30px 0;
				// text-align: center;

				// h2{
				// 	font-size: 32px;
				// 	line-height: 80px;
				// }
				// p{
				// 	width: 100%;
				// 	text-align: center;
				// 	line-height: 1.4;
				// 	padding: 10px 20px;
				// 	box-sizing: border-box;
				// 	font-size: 24px;
				// }
			}
		}
	}
</style>